﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using Doves.Utilities;

namespace Doves.DataAccessLayer.DAO
{
    public class ZombyDAO : IZomby
    {
        private static DoveNewsEntities dataContext;
        private IRepository<Zomby> repository;
        public ZombyDAO()
        {
            dataContext = new DoveNewsEntities();
            repository = new RepositoryDAO<Zomby>(dataContext);
        }

        public IEnumerable<Zomby> GetAllZomby()
        {
            return repository.GetAll();
        }
        
        public Zomby GetCorrespondingZombyOfPageUrl(string inPageUrl)
        {
            //return dataContext.zombies.Where(a => a.url == inPageUrl).SingleOrDefault(b => (Zomby)b);
            return repository.First(o => o.Url == inPageUrl);
        }

        public Zomby GetZombyById(int id)
        {
            return repository.Find(obj => obj.Id == id).Single();
        }
    }
}
